Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move shadow APIs to lib/shadow/ #1197

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Jan 24, 2025


Revisions:

v1b
  • Rebase
$ git range-diff master..gh/shadow shadow/master..shadow
 1:  ca7fc68d !  1:  5882c687 lib/shadow/gshadow/, lib/: putsgent(): Move to separate file
    @@ lib/shadow/gshadow/putsgent.c (new)
     + * writes the result to the given stream.  This is the logical
     + * opposite of fgetsgent.
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +int
     +putsgent(const struct sgrp *sgrp, FILE *fp)
     +{
    @@ lib/shadow/gshadow/putsgent.h (new)
     +#include "gshadow_.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +int putsgent(const struct sgrp *sgrp, FILE *fp);
 2:  900eddbd =  2:  0c2830e3 lib/shadow/gshadow/, lib/: gshadow: Move to separate file and rename
 3:  9e533b79 !  3:  c243ddd9 lib/shadow/gshadow/, lib/, src/: endsgent(): Move to separate file
    @@ lib/shadow/gshadow/endsgent.c (new)
     +#include "shadow/gshadow/gshadow.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +void
     +endsgent(void)
     +{
    @@ lib/shadow/gshadow/endsgent.h (new)
     +#include <config.h>
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +void endsgent(void);
 4:  ed05446b =  4:  02fc437b lib/shadow/gshadow/gshadow.h, lib/, src/: GSHADOW_FILE: Move definition and rename it
 5:  ce49f474 !  5:  8aa68871 lib/shadow/gshadow/, lib/: setsgent(): Move to separate file
    @@ lib/shadow/gshadow/setsgent.c (new)
     +#include "shadow/gshadow/gshadow.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +void
     +setsgent(void)
     +{
    @@ lib/shadow/gshadow/setsgent.h (new)
     +#include <config.h>
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +void setsgent(void);
 6:  72dab352 !  6:  2aa3f65d lib/shadow/gshadow/, lib/, src/: struct sgrp: Move to separate file
    @@ lib/shadow/gshadow/putsgent.h
     +#include "shadow/gshadow/sgrp.h"
      
      
    - #if defined(HAVE_GSHADOW_H)
    + #if __has_include(<gshadow.h>)
     
      ## lib/shadow/gshadow/sgrp.c (new) ##
     @@
    @@ lib/shadow/gshadow/sgrp.h (new)
     +#define SHADOW_INCLUDE_LIB_SHADOW_GSHADOW_SGRP_H_
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp {
 7:  b0d63a72 !  7:  66b0763d lib/shadow/gshadow/, lib/: fgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/fgetsgent.c (new)
     + * fgetsgent() reads the next line from the provided stream and
     + * converts it to a (struct sgrp).  NULL is returned on EOF.
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +struct sgrp *
     +fgetsgent(FILE *fp)
     +{
    @@ lib/shadow/gshadow/fgetsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *fgetsgent(FILE *stream);
 8:  a7822d17 !  8:  51c7ad87 lib/shadow/gshadow/, lib/: sgetsgent(): Move to separate file
    @@ lib/shadow/gshadow/sgetsgent.c (new)
     +#define FIELDS    4
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +static struct sgrp  sgroup = {};
     +
     +
    @@ lib/shadow/gshadow/sgetsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *sgetsgent(const char *);
 9:  1f7b88f4 !  9:  b3a67122 lib/shadow/gshadow/, lib/, src/: getsgnam(): Move to separate file
    @@ lib/shadow/gshadow/getsgnam.c (new)
     +/*
     + * getsgnam - get a shadow group entry by name
     + */
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +struct sgrp *
     +getsgnam(const char *name)
     +{
    @@ lib/shadow/gshadow/getsgnam.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *getsgnam(const char *);
10:  f3b9c46e ! 10:  c3ea1881 lib/shadow/gshadow/, lib/: getsgent(): Move to separate file
    @@ lib/gshadow.c (deleted)
     -
     -#include <config.h>
     -
    --#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    +-#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     -
     -#ident "$Id$"
     -
    @@ lib/shadow/gshadow/getsgent.c (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(SHADOWGRP) && !defined(HAVE_GSHADOW_H)
    ++#if defined(SHADOWGRP) && !__has_include(<gshadow.h>)
     +/*
     + * getsgent - get a single shadow group entry
     + */
    @@ lib/shadow/gshadow/getsgent.h (new)
     +#include "shadow/gshadow/sgrp.h"
     +
     +
    -+#if defined(HAVE_GSHADOW_H)
    ++#if __has_include(<gshadow.h>)
     +# include <gshadow.h>
     +#else
     +struct sgrp *getsgent(void);
11:  f1216144 ! 11:  2b373a55 lib/: GSHADOW: Remove unused macro
    @@ lib/gshadow_.h (deleted)
     -#define SHADOW_INCLUDE_LIB_GSHADOW__H_
     -
     -
    --#if defined(HAVE_GSHADOW_H)
    +-#if __has_include(<gshadow.h>)
     -# include <gshadow.h>
     -#else
     -
    @@ lib/gshadow_.h (deleted)
     -#define   GSHADOW "/etc/gshadow"
     -
     -
    --#endif  // !HAVE_GSHADOW_H
    +-#endif  // !__has_include(<gshadow.h>)
     -#endif  // include guard
12:  64dc60fc = 12:  ca661d7e lib/, po/: sgetgrent(): Move to under lib/shadow/group/
13:  819db775 = 13:  e7293129 lib/, po/: sgetpwent(): Move to under lib/shadow/passwd/

@alejandro-colomar

This comment was marked as outdated.

@alejandro-colomar alejandro-colomar force-pushed the shadow branch 3 times, most recently from 824137b to f8cd3eb Compare January 27, 2025 11:57
@alejandro-colomar alejandro-colomar marked this pull request as ready for review January 27, 2025 12:04
…on and rename it

Rename it for consistency with the file name itself, and with the FILE*
variable that holds the handle to the open file.

Also, we don't need to wrap it in conditionals.  Just define it
unconditionally, and let it be unused if we don't need it.

Signed-off-by: Alejandro Colomar <[email protected]>
And with it, the file that defines it, which does nothing else.

Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant